<!--
 * @Description: pk赛商品审核
 * @Author: liyujie
 * @Date: 2021/08/10
 * @Last Modified by: liyujie
 * @Last Modified time: 2021/08/10
-->
<template>
    <PageLayout
        :title="`校园精英PK赛 - ${title}`"
        class="elite-pk-goods-page-layout"
    >
        <template slot="filter">
            <zd-tabs
                :tab-list="tabsList"
                v-model="filterData.goods_type"
                style="padding-left: 8px"
                @change="handleTabChange()"
            />
            <div class="filter-view">
                <div class="filter-item">
                    <el-radio-group
                        v-model="filterData.verify"
                        size="small"
                        @change="getTableData(1)"
                    >
                        <el-radio-button
                            v-for="item in statusList"
                            :key="item.value"
                            :label="item.value"
                        >
                            {{ item.label }}
                        </el-radio-button>
                    </el-radio-group>
                </div>
                <div class="filter-item">
                    <div class="filter-item__title">
                        商品信息
                    </div>
                    <el-input
                        placeholder="搜索商品编号，商品名称"
                        v-model="filterData.keyword"
                        suffix-icon="el-icon-search"
                        clearable
                        size="medium"
                        style="width: 202px"
                        @keydown.enter.native="getTableData(1)"
                    />
                </div>
                <div class="filter-item">
                    <p class="filter-item__title">
                        店铺名称
                    </p>
                    <el-input
                        placeholder="搜索店铺名称"
                        v-model="filterData.shop_title"
                        suffix-icon="el-icon-search"
                        clearable
                        size="medium"
                        style="width: 202px"
                        @keydown.enter.native="getTableData(1)"
                    />
                </div>
                <div class="filter-item">
                    <p class="filter-item__title">
                        分配状态
                    </p>
                    <el-select
                        v-model="filterData.is_grouping"
                        filterable
                        placeholder="请选择"
                        size="medium"
                        style="width: 152px"
                        @change="getTableData(1)"
                    >
                        <el-option
                            label="全部"
                            :value="99"
                        />
                        <el-option
                            label="已分配"
                            :value="1"
                        />
                        <el-option
                            label="未分配"
                            :value="0"
                        />
                    </el-select>
                </div>
                <div class="filter-item">
                    <el-button
                        type="primary"
                        size="small"
                        @click="getTableData(1)"
                    >
                        查询
                    </el-button>
                    <el-button
                        type="primary"
                        size="small"
                        @click="handleExport()"
                    >
                        导出商品
                    </el-button>
                </div>
            </div>
        </template>
        <el-table
            :data="tableData"
            height="100%"
            style="width: 100%;"
            ref="table"
            class="data-table"
            v-loading="tableLoading"
            row-key="pk_goods_no"
            :cell-style="{height: '140px'}"
            @selection-change="handleSelectedChange"
        >
            <el-table-column
                align="center"
                width="50"
                type="selection"
                fixed="left"
                reserve-selection
                key="0"
            />
            <el-table-column
                width="340"
                label="商品信息"
                fixed="left"
                key="1"
            >
                <template slot-scope="scope">
                    <div class="goods-info">
                        <img
                            :src="scope.row.goods_cover"
                            class="goods-cover"
                            @click="fnShowPreview(scope.row.goods_cover)"
                        >
                        <div class="info">
                            <div class="goods-info__title">
                                {{ scope.row.goods_title }}
                            </div>
                            <div class="goods-info__no">
                                商品编号：{{ scope.row.goods_no }}
                            </div>
                            <el-tooltip
                                class="item"
                                effect="dark"
                                :content="scope.row.shop_title"
                                placement="top"
                            >
                                <div class="goods-info__shop-title">
                                    店铺名称：{{ scope.row.shop_title }}
                                </div>
                            </el-tooltip>

                        </div>
                    </div>
                </template>
            </el-table-column>
            <el-table-column
                label="平台售价"
                show-overflow-tooltip
                align="center"
                width="120"
                key="99"
                v-if="filterData.goods_type !== 1"
            >
                <template slot-scope="scope">
                    ￥{{ scope.row.goods_price }}
                </template>
            </el-table-column>
            <el-table-column
                label="优惠券"
                show-overflow-tooltip
                align="center"
                width="120"
                key="coupon_money"
                v-if="filterData.goods_type !== 1"
            >
                <template slot-scope="scope">
                    ￥{{ scope.row.coupon_money }}
                </template>
            </el-table-column>
            <el-table-column
                label="学生价"
                show-overflow-tooltip
                align="center"
                width="120"
                key="goods_price_pay"
                v-if="filterData.goods_type !== 1"
            >
                <template slot-scope="scope">
                    ￥{{ scope.row.goods_price_pay }}
                </template>
            </el-table-column>
            <el-table-column
                label="活动价"
                show-overflow-tooltip
                align="center"
                width="120"
                key="2"
                v-if="filterData.goods_type === 1"
            >
                <template slot-scope="scope">
                    ￥{{ scope.row.min_activity_price }}起
                    <el-button
                        type="text"
                        @click="showPriceDialog(scope.row)"
                    >
                        查看
                    </el-button>
                </template>
            </el-table-column>
            <el-table-column
                label="原售价"
                show-overflow-tooltip
                align="center"
                width="120"
                key="3"
                v-if="filterData.goods_type === 1"
            >
                <template slot-scope="scope">
                    ￥{{ scope.row.min_product_price }}起
                    <el-button
                        type="text"
                        @click="showPriceDialog(scope.row)"
                    >
                        查看
                    </el-button>
                </template>
            </el-table-column>
            <el-table-column
                prop="buy_limit_count"
                label="活动限购"
                show-overflow-tooltip
                align="center"
                key="12"
                v-if="filterData.goods_type === 1"
            >
                <template slot-scope="scope">
                    {{ scope.row.buy_limit_count === -1 ? '不限' : scope.row.buy_limit_count }}
                </template>
            </el-table-column>
            <el-table-column
                prop="goods_commission_rate"
                label="佣金比例(%)"
                show-overflow-tooltip
                align="center"
                width="120"
                :formatter="emptyFormatter"
                key="4"
            />
            <el-table-column
                label="计费方式"
                show-overflow-tooltip
                align="center"
                key="5"
                v-if="filterData.goods_type === 1"
            >
                <template slot-scope="scope">
                    {{ scope.row.freight_type == 'weight' ? '按重量计费' : (scope.row.freight_type == 'num' ? '按件计费' : (scope.row.freight_type == 'fix' ? '固定邮费' : '--')) }}
                </template>
            </el-table-column>
            <el-table-column
                prop="goods_freight"
                label="商品运费(元)"
                show-overflow-tooltip
                align="center"
                width="110"
                :formatter="emptyFormatter"
                key="6"
                v-if="filterData.goods_type === 1"
            />
            <el-table-column
                prop="reduction_info"
                label="优惠力度"
                align="left"
                key="13"
                v-if="filterData.goods_type === 1"
            >
                <template slot-scope="scope">
                    <div
                        class="cursor-font"
                        v-if="scope.row.reduction_info"
                    >
                        <el-popover
                            placement="left"
                            :width="scope.row.reduction_info.list.length == 0 ? 120 :'auto'"
                        >
                            <div
                                v-if="scope.row.reduction_info.list.length > 0"
                                :style="{width: '100%', textAlign: 'center', display: 'flex', flexDirection: 'column'}"
                            >
                                <div :style="{height: '28px', display: scope.row.reduction_info.list.length > 1 ? 'flex' : '', alignItems: 'center'}">
                                    <div
                                        v-for="(item, index) in scope.row.reduction_info.list"
                                        :key="index"
                                    >
                                        <div
                                            v-if="index <= 2"
                                            class="reduction_price"
                                            :style="{color: scope.row.reduction_info.reduction_type == 2 ? '#FF3030' : '#FDA623', borderColor: scope.row.reduction_info.reduction_type == 2 ? '#FF3030' : '#FDA623', margin: index == 1 ? (scope.row.reduction_info.list.length == 2 ? '0 0 0 12px' : '12px') : '0'}"
                                        >
                                            满{{ item.require_num }}{{ scope.row.reduction_info.reduction_type == 2 ? '' : '件' }}减{{ item.reduction_price }}
                                        </div>
                                    </div>
                                </div>
                                <div
                                    :style="{height: '28px', display: 'flex', alignItems: 'center', marginTop: '18px'}"
                                    v-if="scope.row.reduction_info.list.length > 3"
                                >
                                    <div
                                        v-for="(item, index) in scope.row.reduction_info.list"
                                        :key="index"
                                    >
                                        <div
                                            v-if="index > 2"
                                            class="reduction_price"
                                            :style="{color: scope.row.reduction_info.reduction_type == 2 ? '#FF3030' : '#FDA623', borderColor: scope.row.reduction_info.reduction_type == 2 ? '#FF3030' : '#FDA623', margin: index == 4 ? (scope.row.reduction_info.list.length == 5 ? '0 0 0 12px' : '12px') : '0'}"
                                        >
                                            满{{ item.require_num }}{{ scope.row.reduction_info.reduction_type == 2 ? '' : '件' }}减{{ item.reduction_price }}
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div
                                v-else
                                :style="{width: '100%', textAlign: 'center'}"
                            >
                                暂无数据
                            </div>
                            <el-button
                                slot="reference"
                                type="text"
                            >
                                查看
                            </el-button>
                        </el-popover>
                    </div>
                </template>
            </el-table-column>
            <el-table-column
                label="商家总库存"
                show-overflow-tooltip
                align="center"
                width="110"
                key="8"
                v-if="filterData.goods_type === 1"
            >
                <template slot-scope="scope">
                    {{ scope.row.total_stock }}
                    <el-button
                        type="text"
                        @click="showPriceDialog(scope.row)"
                    >
                        查看
                    </el-button>
                </template>
            </el-table-column>
            <el-table-column
                prop="goods_cate_name_list"
                label="商品组"
                min-width="100"
                show-overflow-tooltip
                key="9"
            >
                <template slot-scope="scope">
                    {{ scope.row.goods_cate_name_list.length > 0 ? scope.row.goods_cate_name_list.join() : '--' }}
                </template>
            </el-table-column>
            <el-table-column
                prop="is_grouping"
                label="分配状态"
                align="center"
                show-overflow-tooltip
                key="is_grouping"
            >
                <template slot-scope="scope">
                    <div class="status-wrapper">
                        <div
                            :class="['status-dot', scope.row.is_grouping ? 'success' : 'danger']"/>
                        {{ scope.row.is_grouping ? '已分配' : '未分配' }}
                    </div>
                </template>
            </el-table-column>
            <el-table-column
                prop="sale_num"
                width="120"
                :render-header="(h, title, content) => renderHeader(h, '活动销量', '活动销量是指该商品在活动期间的销量（如果活动商品是部分SKU参加活动，未报名参加活动的商品SKU为不可购买，对应的SKU置灰）。用户提交订单，活动销量就会增加，取消订单和仅退款，退货退款，活动销量不会减少。')"
                show-overflow-tooltip
                align="center"
                key="10"
            />
            <el-table-column
                prop="act_buy_limit_count"
                label="限购数量"
                show-overflow-tooltip
                align="center"
                key="12"
                v-if="filterData.goods_type === 1"
            >
                <template slot-scope="scope">
                    {{ scope.row.goods_buy_limit_count === -1 ? '不限' : scope.row.goods_buy_limit_count }}
                </template>
            </el-table-column>
            <el-table-column
                label="提交时间"
                align="left"
                min-width="160"
                key="11"
            >
                <template slot-scope="scope">
                    {{ scope.row.create_time * 1000 | dateFormatter('yyyy/MM/dd HH:mm:ss') }}
                </template>
            </el-table-column>
            <el-table-column
                label="历史参与活动次数"
                align="center"
                width="140"
                key="7"
            >
                <template slot-scope="scope">
                    <span>{{ scope.row.goods_join_count }}</span>
                    <el-button
                        type="text"
                        @click="getHistoryList(scope.row)"
                    >
                        查看
                    </el-button>
                </template>
            </el-table-column>
            <el-table-column
                label="审核状态"
                width="150"
                align="center"
                key="14"
            >
                <template slot-scope="scope">
                    <div class="status-wrapper">
                        <div
                            :class="['status-dot', scope.row.verify === 0 ? 'warning' : scope.row.verify === -1 ? 'danger' : scope.row.verify === 1 ? 'success' : 'normal']"/>
                        {{ scope.row.verify | verifyStatusFilter }}
                    </div>
                </template>
            </el-table-column>
            <el-table-column
                label="活动状态"
                align="center"
                width="130"
                key="15"
            >
                <template slot-scope="scope">
                    <div class="status-wrapper">
                        {{ scope.row.status | statusFilter }}
                    </div>
                </template>
            </el-table-column>
            <el-table-column
                label="操作"
                align="left"
                width="180"
                fixed="right"
                key="16"
            >
                <template slot-scope="scope">
                    <div class="option-btn-group">
                        <el-button
                            type="text"
                            :disabled="scope.row.verify === 1 || scope.row.verify === -2"
                            @click="showPassDialog(scope.row)"
                        >
                            通过
                        </el-button>
                        <el-button
                            type="text"
                            :disabled="scope.row.verify === -1 || scope.row.verify === -2"
                            @click="showRejectDialog(scope.row)"
                        >
                            不通过
                        </el-button>
                        <el-button
                            type="text"
                            @click="handleRoute('elitePkGoodsEdit', {
                                pk_goods_no: scope.row.pk_goods_no,
                                pk_no: filterData.pk_no,
                                title, type: 'detail',
                                goods_type: filterData.goods_type,
                                verify_fail_reason: scope.row.verify_fail_reason
                            })"
                        >
                            查看
                        </el-button>
                        <el-button
                            type="text"
                            :disabled="scope.row.verify !== 1 && scope.row.verify !== 0"
                            @click="showGoodsGroup(scope.row)"
                        >
                            分配商品组
                        </el-button>
                        <el-button
                            type="text"
                            v-if="scope.row.verify === -1"
                            @click="showRejectDialog(scope.row, 1)"
                        >
                            驳回原因
                        </el-button>
                        <el-button
                            type="text"
                            @click="setGoodsLimit(scope.row.pk_goods_no, scope.row.buy_limit_count)"
                        >
                            设置限购
                        </el-button>
                    </div>
                </template>
            </el-table-column>
        </el-table>
        <template slot="pagination">
            <div>
                <el-checkbox
                    label="当页全选"
                    v-model="checkAllStatus"
                    :indeterminate="checkIndeterminate"
                    :disabled="tableData.length === 0"
                    @change="handleSelectedAll"
                />
                <el-button
                    type="text"
                    size="medium"
                    style="margin-left: 12px"
                    :disabled="multipleSelection.length === 0"
                    @click="showVerifyBatchDialog(1)"
                >
                    批量通过
                </el-button>
                <el-button
                    type="text"
                    size="medium"
                    style="margin-left: 12px"
                    :disabled="multipleSelection.length === 0"
                    @click="showVerifyBatchDialog(-1)"
                >
                    批量驳回
                </el-button>
                <el-button
                    type="text"
                    size="medium"
                    style="margin-left: 12px"
                    :disabled="multipleSelection.length === 0"
                    @click="setGoodsLimit(multipleSelection.map(item => {return item.pk_goods_no}).join())"
                >
                    批量设置限购
                </el-button>
            </div>
            <el-pagination
                layout="total, prev, pager, next, jumper"
                background
                :current-page.sync="page.now_page"
                :total="page.total_count"
                :page-size="page.page_size"
                @current-change="getTableData"
            />
        </template>
        <!-- 查看价格弹窗 -->
        <el-dialog
            title="查看商品"
            :visible.sync="productVisible"
            width="800px"
            :close-on-click-modal="false"
        >
            <el-table
                :data="detailRow.product_list"
                height="100%"
                style="width: 100%;max-height: 450px"
                class="data-table"
            >
                <el-table-column
                    prop="spec_list"
                    label="规格名称"
                    show-overflow-tooltip
                    :formatter="emptyFormatter"
                >
                    <template slot-scope="scope">
                        {{ scope.row.goods_specs | filterSpec }}
                    </template>
                </el-table-column>
                <el-table-column
                    prop="price"
                    label="活动价(元)"
                    show-overflow-tooltip
                    align="center"
                    :formatter="emptyFormatter"
                />
                <el-table-column
                    prop="product_price"
                    label="原售价(元)"
                    show-overflow-tooltip
                    align="center"
                    :formatter="emptyFormatter"
                />
                <el-table-column
                    prop="product_stock"
                    label="实际库存"
                    show-overflow-tooltip
                    align="center"
                />
            </el-table>
            <span
                slot="footer"
                class="dialog-footer"
            >
                <el-button
                    @click="productVisible = false"
                    size="medium"
                    type="primary"
                >
                    我知道了
                </el-button>
            </span>
        </el-dialog>
        <!--历史参与活动次数弹窗-->
        <el-dialog
            title="查看-历史参与活动"
            :visible.sync="historyDialog"
            width="680px"
            :close-on-click-modal="false"
        >
            <el-table
                :data="historyList"
                height="100%"
                style="width: 100%;max-height: 450px"
                class="data-table"
            >
                <el-table-column
                    label="序号"
                    type="index"
                    width="50"
                    align="center"
                />
                <el-table-column
                    prop="activity_title"
                    label="往期活动名称"
                    show-overflow-tooltip
                />
                <el-table-column
                    prop="price"
                    label="活动价(元)"
                    show-overflow-tooltip
                    align="center"
                    :formatter="emptyFormatter"
                >
                    <template slot-scope="scope">
                        ￥{{ scope.row.min_activity_price }}起
                        <el-popover
                            placement="bottom"
                            width="540"
                            trigger="click"
                            style="margin-left: 10px"
                            popper-class="school-season-goods-verify-history-list"
                        >
                            <el-table :data="scope.row.product_list">
                                <el-table-column
                                    label="商品规格"
                                    show-overflow-tooltip
                                >
                                    <template slot-scope="scope">
                                        {{ scope.row.goods_specs | filterSpec }}
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    label="活动价"
                                    align="center"
                                    show-overflow-tooltip
                                >
                                    <template slot-scope="scope">
                                        ￥{{ scope.row.price }}
                                    </template>
                                </el-table-column>
                            </el-table>
                            <el-button
                                slot="reference"
                                type="text"
                            >
                                查看
                            </el-button>
                        </el-popover>
                    </template>
                </el-table-column>
            </el-table>
            <div
                class="pagination-wrapper"
                style="margin-top: 24px; display: flex; justify-content: flex-end"
            >
                <el-pagination
                    layout="total, prev, pager, next, jumper"
                    background
                    :current-page.sync="dialogPage.now_page"
                    :total="dialogPage.total_count"
                    :page-size="dialogPage.page_size"
                    @current-change="getHistoryList"
                />
            </div>
        </el-dialog>
        <!-- 驳回弹窗 -->
        <reject-dialog
            ref="rejectDialog"
            :visible.sync="rejectDialog"
            :reason-detail="reasonDetail"
            :maxlength="100"
            @confirm="handleExamine(pk_goods_no,-1, $event)"
        />
        <!-- 批量驳回弹窗 -->
        <reject-dialog
            ref="rejectBatchDialog"
            :visible.sync="rejectBatchDialog"
            :maxlength="100"
            @confirm="handleBatchVerify(pk_goods_nos,-1, $event)"
        />
        <!-- /驳回弹窗 -->
        <!-- 图片预览 -->
        <img-preview
            ref="preview"
        />
        <!-- 设置商品组 -->
        <shop-group
            ref="shopGroup"
            @sendData="setGoodsGroup"
        />
    </PageLayout>
</template>

<script>
import { back } from '@/mixin/back';
import ImgPreview from "@/components/common/img-preview";
import RejectDialog from "@/components/dialog/reject-dialog";
import GoodsTypeSelect from "@/components/goods/goods-type-select";
import ShopGroup from "@/components/student/shop-group";
import ZdTabs from "@/components/zd-tabs";
import {setGoodsLimitDialog} from "@/components/elite-pk/set-goods-limit";

export default {
    name: 'ElitePkGoodsVerify',
    mixins: [back],
    components: {ZdTabs, ShopGroup, GoodsTypeSelect, RejectDialog, ImgPreview},
    data() {
        return {
            title: '',
            filterData: {
                pk_no: '',
                shop_title: '',
                keyword: '',
                verify: 99,
                is_grouping: 99,
                goods_type: 1
            },
            tabsList: [
                {label: '自营商品审核', value: 1},
                {label: '淘宝商品审核', value: 2},
                {label: '京东商品审核', value: 11},
                {label: '拼多多商品审核', value: 12},
            ],
            tableData: [],
            tableLoading: false,
            page: {
                now_page: 1,
                total_count: 0,
                page_size: 20
            },
            statusList: [
                {label: '全部', value: 99},
                {label: '待审核', value: 0},
                {label: '审核通过', value: 1},
                {label: '审核不通过', value: -1},
                {label: '取消报名', value: -2},
            ],
            // 价格弹窗
            productVisible: false,
            detailRow: {},
            pk_goods_no: '',
            pk_goods_nos: '',
            rejectBatchDialog: false,
            rejectDialog: false,
            reasonDetail: '',
            checkAllStatus: false,
            checkIndeterminate: false,
            multipleSelection: [],
            goods_nos: [],
            // 活动历史数据
            historyDialog: false,
            historyList: [],
            dialogPage: {
                now_page: 1,
                total_count: 0,
                page_size: 5
            },
        };
    },
    computed: {},
    watch: {},
    filters: {
        verifyStatusFilter(val) {
            switch (val) {
                case 0:
                    return '待审核';
                case 1:
                    return '已通过';
                case -1:
                    return '未通过';
                case -2:
                    return '取消报名';
                default:
                    return '--';
            }
        },
        statusFilter(val) {
            switch (val) {
                case 0:
                    return '报名未开始';
                case 1:
                    return '报名进行中';
                case 2:
                    return '报名已结束';
                case 3:
                    return '活动进行中';
                case 4:
                    return '活动已结束';
                case 5:
                    return '活动已下架';
                default:
                    return '--';
            }
        },
        filterSpec (val) {
            if(!val) return '';
            let str = '';

            val.forEach(el => {
                str += el.spec_name + ':' + el.spec_value + ';';
            });
            return str;
        }
    },
    mounted() {
        let query = this.$route.query;
        let filterData = JSON.parse(sessionStorage.getItem('PK_GOODS_QUERY'));

        this.$store.commit('SET_HEADER', [{title: "APP后台"}, {title: '校园精英PK赛'}, {title: '活动列表', path: '/student/elite-pk-activity-list'}, {title: '商品审核'}]);
        this.authResult = this.$route.meta.authResult;
        if (filterData) {
            this.filterData = filterData;
            this.page.now_page = Number(sessionStorage.getItem('PK_GOODS_PAGE_NO'));
            sessionStorage.removeItem('PK_GOODS_QUERY');
            sessionStorage.removeItem('PK_GOODS_PAGE_NO');
        }
        this.filterData.pk_no = query.pk_no;
        this.title = query.title;
        this.getTableData();
    },

    methods: {

        /**
         * @description 获取列表数据
         * @param page
         */
        getTableData(page) {
            this.tableLoading = true;
            let params = { ...this.filterData };

            params.page_id = page || this.page.now_page;
            this.$post('/student/task_stuagent_extra_pk_activity%5Cshop_apply%5Cget_list', params, res => {
                if (res.code === 1) {
                    this.tableData = res.data.list;
                    this.page = res.data.page;
                } else {
                    this.$notify({
                        title: '提示',
                        message: res.msg,
                        type: 'warning'
                    });
                }
                this.tableLoading = false;
            });
        },

        /**
         * 路由跳转
         */
        handleTabChange() {
            // this.filterData.goods_type = active;
            this.getTableData(1);
            this.$nextTick(() => {
                this.$refs.table.doLayout();
            });
        },

        /**
         * 路由跳转
         * @param routeName
         * @param query
         */
        handleRoute(routeName, query) {
            this.$router.push({
                name: routeName,
                query
            });

            sessionStorage.setItem('PK_GOODS_QUERY', JSON.stringify(this.filterData));
            sessionStorage.setItem('PK_GOODS_PAGE_NO', this.page.now_page);
        },

        /**
         * @description 过滤函数
         */
        emptyFormatter(row, column, val) {
            if (!val) return '--';
            return val;
        },

        /**
         * 预览图片
         * @param   {String}    images      //单图预览
         * @param   {Array}     images      //多图预览
         * @param index
         */
        fnShowPreview(images, index) {
            if (images && Object.prototype.toString.call(images) == '[object String]') {
                this.$refs.preview.show([
                    images
                ]);
            } else if (images && Object.prototype.toString.call(images) == '[object Array]') {
                this.$refs.preview.show(images, index);
            } else {
                this.$message({
                    type: 'warning',
                    message: '图片类型错误'
                });
            }
        },

        /**
         * 显示详细价格弹窗
         * @param row
         */
        showPriceDialog(row) {
            this.detailRow = row;
            this.productVisible = true;
        },

        /**
         * 审核通过提示弹窗
         * @param row
         */
        showPassDialog(row) {
            if(!this.authResult.auth_verify) {
                this.$notify({
                    title: '提示',
                    message: '请联系管理员添加权限',
                    type: 'warning',
                    duration: 2000
                });
                return false;
            }
            this.$zdConfirm('是否确认通过该商品审核？', '审核通过提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.handleExamine(row.pk_goods_no, 1);
            });
        },

        /**
         * 驳回弹窗
         * @param type - 0填写驳回原因  1回显原因
         * @param row
         */
        showRejectDialog(row, type = 0) {
            if(type === 1) {
                // 回显
                this.reasonDetail = row.verify_fail_reason;
                this.rejectDialog = true;
            } else {
                if(!this.authResult.auth_verify) {
                    this.$notify({
                        title: '提示',
                        message: '请联系管理员添加权限',
                        type: 'warning',
                        duration: 2000
                    });
                    return false;
                }
                // 填写
                this.pk_goods_no = row.pk_goods_no;
                this.$refs.rejectDialog.reason = '报名商品不符合该活动报名条件';
                this.reasonDetail = '';
                this.rejectDialog = true;
            }
        },

        /**
         * 审核
         * @param verify - 1通过  -1拒绝
         * @param verify_fail_reason - 拒绝原因
         * @param pk_goods_no - 编号
         */
        handleExamine(pk_goods_no, verify, verify_fail_reason = '') {
            let params = {
                pk_goods_no,
                verify_fail_reason,
                verify
            };

            this.$post('/student/task_stuagent_extra_pk_activity%5Cshop_apply%5Caudit', params, resp => {
                if (resp.code === 1) {
                    this.rejectDialog = false;
                    this.getTableData();
                    this.$notify({
                        title: '成功',
                        message: '操作成功',
                        duration: 2000,
                        type: 'success'
                    });
                } else {
                    this.$notify({
                        title: '提示',
                        message: resp.msg,
                        duration: 2000,
                        type: 'warning'
                    });
                }
            });
        },

        /**
         * 点击全选
         * @param val
         */
        handleSelectedAll(val) {
            if(val) {
                this.$refs.table.toggleAllSelection();
            } else {
                this.$refs.table.clearSelection();
            }
            this.checkIndeterminate = false;
        },

        /**
         * 批量审核通过或者拒绝
         * @param verify - 1通过 -1拒绝
         */
        showVerifyBatchDialog(verify) {
            this.pk_goods_nos = this.multipleSelection.map(item => {
                return item.pk_goods_no;
            }).join();
            if(verify === 1) {
                this.$zdConfirm('是否确认通过该商品审核？', '审核通过提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.handleBatchVerify(this.pk_goods_nos, 1);
                }).catch(() => {});
            } else {
                this.rejectBatchDialog = true;
            }
        },


        /**
         * 批量审核
         * @param verify - 1通过  -1拒绝
         * @param verify_fail_reason - 拒绝原因
         * @param pk_goods_nos - 编号
         */
        handleBatchVerify(pk_goods_nos, verify, verify_fail_reason = '') {
            let params = {
                pk_goods_nos,
                verify,
                verify_fail_reason
            };

            this.$post('/student/task_stuagent_extra_pk_activity%5Cshop_apply%5Caudit_batch', params, resp => {
                if (resp.code === 1) {
                    this.getTableData();
                    this.$refs.table.clearSelection();
                    this.$notify({
                        title: '成功',
                        message: '操作成功',
                        duration: 2000,
                        type: 'success'
                    });
                } else {
                    this.$notify({
                        title: '提示',
                        message: resp.msg,
                        duration: 2000,
                        type: 'warning'
                    });
                }
            });
        },

        /**
         * 选中
         * @param selection
         */
        handleSelectedChange(selection) {
            let checkedCount = selection.length;

            this.multipleSelection = selection;
            this.checkAllStatus = checkedCount === this.tableData.length;
            this.checkIndeterminate = checkedCount > 0 && checkedCount < this.tableData.length;
        },

        /**
         * 显示商品组弹窗
         * @param row
         */
        showGoodsGroup(row) {
            this.$post('/student/shop_goods%5Ccurrent_cate', {
                goods_no: row.goods_no
            }, resp => {
                if (resp.code === 1) {
                    this.goods_nos = [row.goods_no];
                    if(Object.prototype.toString.call(resp.data) !== '[object Null]' && resp.data.list.length > 0) {
                        this.$refs.shopGroup.getType('edit', {
                            data: resp.data,
                            goods_no: row.goods_no
                        });
                        this.$refs.shopGroup.show();
                    } else {
                        this.$refs.shopGroup.show();
                        this.$refs.shopGroup.getType('add');
                        this.$refs.shopGroup.getNext(true);
                        return false;
                    }
                } else {
                    this.$notify({
                        title: '提示',
                        type: 'warning',
                        message: resp.msg
                    });
                }
            });
        },

        /**
         * 分配商品组
         * @param val
         */
        setGoodsGroup(val) {
            console.log(val);
            this.$post('/student/shop_goods%5Cjoin_cate', {
                goods_nos: this.goods_nos.join(),
                data_nos: val.data.join()
            }, resp => {
                if (resp.code === 1) {
                    this.$refs.shopGroup.hide();
                    this.getTableData();
                    this.$notify({
                        title: '提示',
                        type: 'success',
                        message: '操作成功'
                    });
                } else {
                    this.$notify({
                        title: '提示',
                        type: 'warning',
                        message: resp.msg
                    });
                }
            });
        },

        /**
         * 自定义表格标题hover提示
         */
        renderHeader(h,title, content){
            return h('span', {}, [
                h('span', {style: 'font-weight: bold'}, title),
                h('el-popover', { props: { placement: 'top-start', width: '200', trigger: 'hover', content: content }}, [
                    h('i', { slot: 'reference', class:'el-icon-question', style: 'color:#666;margin-left: 6px'}, '')
                ])
            ]);
        },

        /**
         * 导出数据
         */
        handleExport() {
            let base = this.$baseUrl;
            let params = {...this.filterData};
            let ticket = localStorage.getItem('sessionTicket');
            let queryStr = Object.keys(params)
                .map(key => `${key}=${params[key]}`)
                .join('&');
            let url = `${base}/student/task_stuagent_extra_pk_activity%5Cshop_apply%5Cexport_list?${queryStr}&__ticket=${ticket}`;

            window.open(url);
        },

        /**
         * 显示历史活动弹窗
         * @param row
         */
        getHistoryList(row) {
            this.$post('/student/task_stuagent_extra_pk_activity%5Cshop_apply%5Cget_goods_join_history_list', {
                goods_no: row.goods_no,
                page_id: this.dialogPage.now_page
            }, resp => {
                if (resp.code === 1) {
                    this.historyDialog = true;
                    this.historyList = resp.data.list;
                    this.dialogPage = resp.data.page;
                } else {
                    this.$notify({
                        title: '提示',
                        type: 'warning',
                        message: resp.msg
                    });
                }
            });
        },

        /**
         * 设置限购
         * @param pk_goods_nos
         * @param default_value
         */
        async setGoodsLimit(pk_goods_nos, default_value) {
            let buy_limit_count = await setGoodsLimitDialog({
                default_value
            });

            if(buy_limit_count) {
                this.$post('/student/task_stuagent_extra_pk_activity%5Cshop_apply%5Cset_buy_limit_count', {
                    pk_goods_nos,
                    buy_limit_count,
                }, resp => {
                    if (resp.code === 1) {
                        this.$notify({
                            title: '提示',
                            type: 'success',
                            message: '设置成功'
                        });
                        this.getTableData();
                    } else {
                        this.$notify({
                            title: '提示',
                            type: 'warning',
                            message: resp.msg
                        });
                    }
                });
            }
        }
    }
};
</script>

<style lang="less" scoped>
.elite-pk-goods-page-layout {
    /deep/ .content-wrapper {
        .header {
            display: none;
        }
        .filter-wrapper {
            display: initial!important;
            margin-top: 0!important;
            padding: 0!important;
            .filter-view {
                display: flex;
                flex-wrap: wrap;
                padding: 0 24px;
                margin-top: 24px;
            }
        }
    }
}
.goods-info {
    display: flex;
    align-items: center;
    .goods-cover {
        width: 108px;
        height: 108px;
        cursor: pointer;
        margin-right: 16px;
        flex-shrink: 0;
    }
    .info {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        font-size: 12px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #333333;
        .goods-info__title {
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #333333;
            font-size: 14px;
            display: -webkit-box;
            overflow: hidden;
            -webkit-line-clamp: 2;
            margin-bottom: 8px;
            /*! autoprefixer: off */
            -webkit-box-orient: vertical;
        }
        .goods-info__shop-title {
            width: 200px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space:nowrap;
        }
        .goods-info__no {
            margin-bottom: 8px;
        }
    }
}

/* 字体高亮 */
.cursor-font {
    color: rgb(64, 158, 255);
    cursor: pointer;
}

/* 排序 */
.sort-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    .sort-spliter {
        width: 1px;
        height: 12px;
        background: rgba(235, 235, 235, 1);
        margin: 0 10px;
    }
    .btn-sort {
        font-size: 14px;
        line-height: 1;
        color: #ccc;
        &:hover {
            color: #20a0ff;
        }
    }
}

.dialog-footer {
    display: flex;
    justify-content: center;
}
</style>

<style lang="less">
.school-season-goods-verify-history-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 32px;
}
</style>
